package cn.outsourcing.supermarket.mapper;

import cn.outsourcing.supermarket.bo.HiolabsGoodsSpecificationBO;
import cn.outsourcing.supermarket.po.HiolabsCart;
import cn.outsourcing.supermarket.provider.CartProvider;
import cn.outsourcing.supermarket.vo.cart.AddCartListVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * Mapper 接口
 *
 * @author gzkemays
 * @since 2021-10-14
 */
@Mapper
public interface HiolabsCartMapper extends BaseMapper<HiolabsCart> {
  /**
   * 通过用户 id 获取购物车列表信息
   *
   * @param userId 用户id
   * @return {@link AddCartListVO}
   */
  @SelectProvider(value = CartProvider.class, method = "getAddCartList")
  List<AddCartListVO> getAddCartList(Integer userId);

  /**
   * 通过订单 id 获取购物车列表信息
   *
   * @param orderId 订单 id
   * @param userId 用户 id
   * @return 购物车商品列表
   */
  @SelectProvider(value = CartProvider.class, method = "getOrderCartList")
  List<AddCartListVO> getOrderCartList(
      @Param(value = "orderId") Integer orderId, @Param(value = "userId") Integer userId);
  /**
   * 根据产品的 id 获取商品和规格合并结果
   *
   * @param productId 产品 id
   * @return {@link HiolabsGoodsSpecificationBO} 合并业务对象
   */
  @SelectProvider(value = CartProvider.class, method = "getGoodsSpecificationMerge")
  HiolabsGoodsSpecificationBO getGoodsSpecificationMerge(Integer productId);
}
